﻿/*
	Copyright © Bogdan Kobets 2011
	http://ElasticLogic.com
*/

using ElasticLogic.TagsMarker.Concepts;

namespace ElasticLogic.TagsMarker.Collections
{

	public class LabelsCollection<L> : CommonCollection<L>
		where L : Label
	{

		public LabelsCollection()
			: base(true)
		{
		}

		public L this[string caption]
		{
			get
			{
				foreach (L item in base.Items)
				{
					if (item.Caption == caption)
						return item;
				}
				return null;
			}
		}

		public bool Contains(string caption)
		{
			foreach (L item in base.Items)
			{
				if (item.Caption == caption)
					return false;
			}
			return true;
		}

		public bool Add(L item)
		{
			if (this.Contains(item.Caption))
				return false;

			return base.AddItem(item);
		}

	}

}
